#include "error.h"
#include "tcpip.h"

int resolve(char *hostname, struct in_addr *ip) {
    struct hostent *h;
    if (!hostname || !*hostname)
        fatal("NULL of zero-length hostname passed to resolve()");

    if (inet_aton(hostname, ip))
        return 1;
    if ((h = gethostbyname(hostname))) {
        memcpy(ip, h->h_addr_list[0], sizeof(struct in_addr));
        return 1;
    }
    return 0;
}

